from psycopg_pool import ConnectionPool

with ConnectionPool("dbname=examdb user=examdb", min_size=4) as pool:
	with pool.connection() as conn:
		with conn.cursor() as cur:
			cur.execute("""
			SELECT s.name, c.name, g.grade 
			FROM course_grade as g
				LEFT OUTER JOIN student as s ON g.stu_sn = s.sn
				LEFT OUTER JOIN course as c  ON g.cou_sn = c.sn
			""")

			for row in cur:
				print(f"{row[0]}, {row[1]}, {row[2]}")

	print(pool.get_stats())

